#ifndef _SPI_INIT_H
#define _SPI_INIT_H

#include "sys.h"
#include "delay.h"
	
#define SPI1_SCK							GPIO_PIN_3//CLK	时钟
#define SPI1_SCK_Periph_GPIO				GPIOF
			
#define SPI1_MISO							GPIO_PIN_5//MISO 主进从出
#define SPI1_MISO_Periph_GPIO				GPIOF
			
#define SPI1_MOSI							GPIO_PIN_4//MOSI 主出从进
#define SPI1_MOSIPeriph_GPIO				GPIOF
			
#define Mipi283228_DC								GPIO_PIN_1
#define Mipi283228_DC_Periph_GPIO					GPIOF

#define Mipi2832_CS1						GPIO_PIN_2
#define Mipi2832_CS_Periph_GPIO				GPIOF		

//#define M25P64_CS0							GPIO_PIN_2 //  M25P64片选
//#define M25P64_CS_Periph_GPIO				GPIOF

#define CS1 	0X01
#define CS2		0x02
#define CS1_2	0x03

void SPI1_IO_init(void);
void SPI_CS_Select(u8 channel,u8 Enable);
void SPI_Write_u8_Cmd(u8 SPI_Mode,u8 channel,u8 cmd);
void SPI_Write_u8_Cmd_NoCS(u8 SPI_Mode,u8 cmd);
void SPI_Write_u8_Data(u8 SPI_Mode,u8 channel,u8 data);
void SPI_Write_u8_Data_NoCS(u8 SPI_Mode,u8 data);
void SPI_Write_2P3T_Data_NoCS(u16 data);
u8   SPI3_Read_u8_Data(u8 channel);
u8   SPI3_Read_u8_Data_NoCS(void);
u16  SPI3_Read_u16_Data(u8 channel);
u8 SPI4_Read_u8_Data(u8 SPI_Mode,u8 channel ,u8 cmd);
u8 SPI4_Read_u8_Data_page(u8 SPI_Mode,u8 channel ,u8 page ,u8 cmd);
void SPI_Write_u8_Array(u8 SPI_Mode,u8 channel ,u8* para);
void SPI_Set_Window(u8 SPI_Mode,u8 channel ,u16 x0,u16 x1,u16 y0,u16 y1);
void SPI_WriteRAM_buffer_part(u8 SPI_Mode,u8 channel ,u8* buffer ,u16 length,u8  multiple ,u8 Flag,u8 DUAL_SPI_MODE);
void SPI3_WriteRAM(u8 SPI_Mode,u8 channel ,u16 H_OLED,u16 V_OLED,u8 R,u8 G, u8 B, u8 flag);
void SPI_Write_u8_Array_code(u8 SPI_Mode,u8 channel ,u8* para);
u8 SPI4_Read_u8_Data_array(u8 SPI_Mode,u8 channel ,u8* para);
u8 SPI4_Read_u8_Data_array_SDA(u8 SPI_Mode,u8 channel ,u8* para);

#endif


